package cn.org.tpeach.nosql.bean;

import cn.org.tpeach.nosql.redis.bean.RedisKeyData;
import cn.org.tpeach.nosql.tools.ConfigParserUtils;
import cn.org.tpeach.nosql.tools.StringUtils;
import lombok.Data;

/**
 * @author tyz
 * @Title: RedisKeyDataVo
 * @ProjectName Redis-Lettuce-Parent
 * @Description: TODO
 * @date 2020-06-06 9:18
 * @since 2.0.0
 */
@Data
public class RedisKeyDataVo {
    private int index;
    private  Double score;
    private String field;
    //set zset -> member
    private String value;
    private RedisKeyDataVo(){

    }
    public static RedisKeyDataVo build(RedisKeyData redisKeyData){
        RedisKeyDataVo redisKeyDataVo = new RedisKeyDataVo();
        redisKeyDataVo.index = redisKeyData.getIndex();
        redisKeyDataVo.score = redisKeyData.getScore();
        if(redisKeyData.getField() != null){
            redisKeyDataVo.field = StringUtils.showHexStringValue(ConfigParserUtils.getInstance().byteToStr(redisKeyData.getField()));
        }
        if(redisKeyData.getValue() != null){
            redisKeyDataVo.value = StringUtils.showHexStringValue(ConfigParserUtils.getInstance().byteToStr(redisKeyData.getValue()));
        }
        return redisKeyDataVo;
    }



}
